﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DataLayer;

public partial class Widgets_WidgetBox_wb : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      int InstanceID = Typecast.ToInt32(Request.QueryString["id"]);
      if (InstanceID > 0)
      {
         Guid UserKey = Functions.GetUserProviderKey();
         try
         {
            using (var db = DatabaseHelper.GetDashboardData())
            {
               //need to ensure user has access to this data
               var WI = (from p in db.TabWidgets
                         where p.Id == InstanceID
                         select p).First();

               var UserT = (from T in WI.Tab.UserTabs
                            where T.UserID == UserKey
                            select T).First();
               if (UserT != null)
               {
                  XElement State = XElement.Parse(WI.State);
                  lbl.Text = State.Element("Embed").Value;
               }
            }
         }
         catch (Exception ex)
         {
            lbl.Text = ex.ToString();
         }
      }
   }
}
